package _case

import (
	"fmt"
)

type user struct {
	Name string
	Age  int
	Address
}

type Address struct {
	Pri string
	lll int
}

func StructCase() {
	u := user{
		Name: "awngxd",
		Age:  20,
	}
	f2(&u)
	fmt.Println(u)

	//指针类型
	u1 := &user{
		Name: "awnaskjldfha",
		Age:  45,
	}
	fmt.Println(u1)  //指针类型
	fmt.Println(*u1) //指针取值

	//new
	u2 := new(user) //开辟一块地址空间
	u2.Age = 20
	fmt.Println(u2)
	u2.Name = "asdjkhakd"
	u2.Address.Pri = "test"
	fmt.Println(*u2, u2.Address.Pri)

	//结构体为值类型，定义变量后被默认初始化
	var n3 user
	n3.Address.Pri = "n3"
	fmt.Println(n3)
}
func f2(u *user) {
	u.Age = 22
}
